home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / laser.zip / BIN_TEST.PAS < prev    next >
Pascal/Delphi Source File  |  1988-03-26  |  2KB  |  53 lines

  1. Program Bin_test;
  2. {This program test the ability of the plotting program to handle
  3.  binary data files.}
  4.  
  5. Var
  6.   Data_file:    File of real;
  7.   I:            Integer;
  8.   J:            Integer;
  9.   No_of_lines:  Real;
  10.   No_of_points: Real;
  11.   Data:         Real;
  12.   Negative_one: Real;
  13.   Zero:         Real;
  14.   Header1:      String[50];
  15.   Header2:      String[50];
  16.   RealOrd:      Real;
  17.  
  18. Begin
  19.   Negative_one := -1.0;
  20.   Zero := 0.0;
  21.   Header1 := 'Binary data file: example data';
  22.   Header2 := '(This label is included in the data file)';
  23.   No_of_lines := 2.0;
  24.   No_of_points := 5.0;
  25.   Assign(Data_file, 'Bin_test.dat');
  26.   Rewrite(Data_file);
  27.  
  28.   {This section shows the method by which a label may be placed in a binary
  29.    data file.  It could be omitted entirely and the program would still work.}
  30.   Write(Data_file, negative_one);    {indicates a label is in the file}
  31.   For I:=1 to Length(Header1) do     {Write header 1}
  32.   Begin
  33.     RealOrd := Ord(Header1[I]);      {Find a real number which is the}
  34.     Write(Data_file, RealOrd);       {  ascii value for the character}
  35.   End;
  36.   Write(Data_file, Zero);            {Indicates the end of header1}
  37.   For I:=1 to Length(Header2) do     {Write header 2}
  38.   Begin
  39.     RealOrd := Ord(Header2[I]);      {Find a real number which is the}
  40.     Write(Data_file, RealOrd);       {  ascii value for the character}
  41.   End;
  42.   Write(Data_file, Zero);            {Indicates the end of header2}
  43.  
  44.   Write(Data_file, No_of_lines);
  45.   Write(Data_file, No_of_points);
  46.   For I:=1 to Round(No_of_lines) do
  47.     For J:=1 to Round(No_of_points) do
  48.     Begin
  49.       Data := 1.0 * I / J;
  50.       Write(Data_file, Data);
  51.     End;
  52.   Close(Data_file);
  53. End.